Hierarchical XML File Examples

Example 1: Importing a Problem and Incident

Example 2: Importing Multiple Incidents

Example 1: Importing a Problem and Incident

This topic provides an example of a source document that is in XML (Problem-Incident-raw.xml), but not in the hierarchical XML format.

You can upload that file using the hierarchical XML import by applying the Problem-Incident.xsl XSL file.

Internally, this transforms the file to be like the Problem-Incident.xml file, which does conform to the hierarchical XML format, and can then be imported.

Example 1 Source

Example 1 XSL File

Example 1 Output

Example 1 Source

<?xml version="1.0" encoding="UTF-8"?>

<Problem>

<ProblemNumber>1000002</ProblemNumber>

<Subject>Update antivirus on AV Servers</Subject>

<ErrorMessage>Installation failed with error code: xxxxxx</ErrorMessage>

<Description>The AV on the network security</Description>

<Status>Active</Status>

<Category>Accessibility</Category>

<Source>Instant Message</Source>

<OwnerTeam>Problem Management</OwnerTeam>

<Owner>ADale</Owner>

<Urgency>Low</Urgency>

<Urgency>High</Urgency>

<Incidents>

<Incident>

<IncidentNumber>50001</IncidentNumber>

<Subject>Daily Backup Failure</Subject>

<Symptom>Backup failed on server</Symptom>

</Incident>

</Incidents>

</Problem>

Example 1 XSL File

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">

<BusinessObjectList xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0">

<BusinessObject Name="Problem">

<Transaction>UpdateAdd</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="ProblemNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ProblemNumber">

<xsl:value-of select="Problem/ProblemNumber"/>

</Field>

<Field Name="Subject">

<xsl:value-of select="Problem/Subject"/>

</Field>

<Field Name="ErrorMessage">

<xsl:value-of select="Problem/ErrorMessage"/>

</Field>

<Field Name="Description">

<xsl:value-of select="Problem/Description"/>

</Field>

<Field Name="Status">

<xsl:value-of select="Problem/Status"/>

</Field>

<Field Name="Category">

<xsl:value-of select="Problem/Category"/>

</Field>

<Field Name="Source">

<xsl:value-of select="Problem/Source"/>

</Field>

<Field Name="OwnerTeam">

<xsl:value-of select="Problem/OwnerTeam"/>

</Field>

<Field Name="Owner">

<xsl:value-of select="Problem/Owner"/>

</Field>

<Field Name="Impact">

<xsl:if test="Problem/Impact">

<xsl:value-of select="Problem/Impact"/>

</xsl:if>

<xsl:if test="not(Problem/Impact)">

<xsl:text>Low</xsl:text>

</xsl:if>

</Field>

<Field Name="Urgency">

<xsl:value-of select="Problem/Urgency"/>

</Field>

</FieldList>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="ProblemAssociatesIncident">

<BusinessObject Name="Incident">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<xsl:for-each select="Problem/Incidents/Incident">

<Field Name="IncidentNumber">

<xsl:value-of select="IncidentNumber"/>

</Field>

<Field Name="Subject">

<xsl:value-of select="Subject"/>

</Field>

<Field Name="Symptom">

<xsl:value-of select="Symptom"/>

</Field>

</xsl:for-each>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

</xsl:template>

</xsl:stylesheet>

Example 1 Output

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0">

<BusinessObject Name="Problem">

<Transaction>UpdateAdd</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="ProblemNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ProblemNumber">1000002</Field>

<Field Name="Subject">Update antivirus on AV Servers</Field>

<Field Name="ErrorMessage">Installation failed with error code: xxxxxx</Field>

<Field Name="Description">The AV on the network security</Field>

<Field Name="Status">Active</Field>

<Field Name="Category">Accessibility</Field>

<Field Name="Source">Instant Message</Field>

<Field Name="OwnerTeam">Problem Management</Field>

<Field Name="Owner">ADale</Field>

<Field Name="Impact">Low</Field>

<Field Name="Urgency">High</Field>

</FieldList>

<RelatedBusinessObjectList>

<RelatedBusinessObject Relationship="ProblemAssociatesIncident">

<BusinessObject Name="Incident">

<Transaction>None</Transaction>

<LinkTransaction>Link</LinkTransaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name=""IncidentNumber">50001</Field>

<Field Name="Subject">Daily Backup Failure</Field>>

<Field Name="Symptom">Backup failed on server</Field>

</FieldList>

</BusinessObject>

</RelatedBusinessObject>

</RelatedBusinessObjectList>

</BusinessObject>

</BusinessObjectList>

Example 2: Importing Multiple Incidents

This example shows how to import multiple incidents. The transaction is updateAdd, meaning that if the incident number exists, the application updates the incident, but if the incident number does not exist, the application creates the incident. The first record does not include an incident number, so the application creates a new incident. The second record contains an incident number; if that incident already exists, the application updates it, but if it does not exist, the application creates it.

Below, find the following:

Example 2 Source

Example 2 XSLT File

Example 2 Output

Example 2 Source

<?xml version="1.0"?>

<Incidents>

<Incident>

<Customer>Administrator Admin</Customer>

<Summary>test1</Summary>

<Category>Connectivity</Category>

<Description>test1</Description>

</Incident>

<Incident>

<IncidentNumber>10928</IncidentNumber>

<Customer>Administrator Admin</Customer>

<Summary>test21</Summary>

<Category>Connectivity</Category>

<Description>test2 description1</Description>

</Incident>

</Incidents>

Example 2 XSLT File

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">

<BusinessObjectList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="1.0" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd">

<xsl:apply-templates/>

</BusinessObjectList>

</xsl:template>

<xsl:template match="/Incidents/Incident">

<BusinessObject Name="Incident">

<Transaction>UpdateAdd</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<xsl:if test="IncidentNumber">

<Field Name="IncidentNumber">

<xsl:value-of select="./IncidentNumber"/>

</Field>

</xsl:if>

<Field Name="ProfileLink">

<xsl:value-of select="./Customer"/>

</Field>

<Field Name="Subject">

<xsl:value-of select="./Summary"/>

</Field>

<Field Name="Category">

<xsl:value-of select="./Category"/>

</Field>

<Field Name="Symptom">

<xsl:value-of select="./Description"/>

</Field>

</FieldList>

</BusinessObject>

</xsl:template>

</xsl:stylesheet>

Example 2 Output

<?xml version="1.0" encoding="UTF-8"?>

<BusinessObjectList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HierarchicalObjects-1.0.xsd" SchemaVersion="1.0">

<BusinessObject Name="Incident">

<Transaction>UpdateAdd</Transaction>

<UniqueKeyList>

<UniqueKey>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="ProfileLink">Administrator Admin</Field>

<Field Name="Subject">test1</Field>

<Field Name="Category">Connectivity</Field>

<Field Name="Symptom">test1</Field>

</FieldList>

</BusinessObject>

<BusinessObject Name="Incident">

<Transaction>UpdateAdd</Transaction>

<UniqueKeyList>

<FieldList>

<Field Name="IncidentNumber"/>

</UniqueKey>

</UniqueKeyList>

<FieldList>

<Field Name="IncidentNumber">10928</Field>

<Field Name="ProfileLink">Administrator Admin</Field>

<Field Name="Subject">test2</Field>

<Field Name="Category">Connectivity</Field>

<Field Name="Symptom">test2</Field>

</FieldList>

</BusinessObject>

</BusinessObjectList>